
#pragma once

#include <ttg/math.h>

using namespace ttg::math;

//Represents 3D sphere and provides some used routines.
class Sphere
{
	public:
		vec3f center;
		float radius;

		//Creates zero sphere.
		TTG_INLINE Sphere()
		{
			center = vec3f(0.0f, 0.0f, 0.0f);
			radius = 0.0f;
		}
		//Creates sphere with required center and radius.
		TTG_INLINE Sphere(vec3f center, float radius)
		{
			this->center = center;
			this->radius = radius;
		}
		//Returns depth of intersection for two given spheres.
		//If they are not intersected, returns zero.
		static TTG_INLINE float findIntersectionDepth(const Sphere s1,
													  const Sphere s2)
		{
			float depth = s2.radius + s1.radius - (s2.center - s1.center).getLength();
			return depth <= 0.0f ? 0.0f : depth;
		}
};
